package com.klxedu.ms.gateway.security.session;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import com.klxedu.ms.gateway.AuthServerConstants;
/**
 * 
 * Title: CustomSessionInformationExpiredStrategy<br>
 * Description: 多账号登录后，session过期提示扩展类<br>
 * Copyright @ 2011~2018 Goldgov .All rights reserved.<br>
 * 
 * @author GuoR
 * @createDate 2018年7月16日
 */
public class CustomSessionInformationExpiredStrategy implements SessionInformationExpiredStrategy {

	@Override
	public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
		HttpServletResponse response = event.getResponse();
		response.sendError(AuthServerConstants.SC_MULTIPLE_ACCOUNT, "相同的账号已在其它设备上登录，请重新登录。");
		response.flushBuffer();

	}

}
